import request from "@/utils/request.js";

//获取帖子
export const getBlogList = (data) => {
	return request.get('blog/queryBlogList', {
		pageNum: 1,
		pageSize: 5,
		...data
	}, {
		noAuth: true
	})
}

// 点赞帖子
export const likeBlog = (data) => {
	return request.put(`blog/like/${data}`, {}, {
		noAuth: true
	})
}

// 根据id查找帖子
export const findBlog = (data) => {
	return request.get(`blog/${data}`, {}, {
		noAuth: true
	})
}

// 根据id删除帖子
export const deleteBlogById = (id) => {
	return request.delete(`blog/${id}`)
}
// 根据id举报帖子
export const reportBlogById = (id) => {
	return request.get(`blog/report?id=${id}`)
}
// 根据id删除评论
export const deleteCommentById = (id) => {
	return request.delete(`blog-comments/deleteCommentById/${id}`)
}
// 根据id举报评论
export const reportCommentById = (id) => {
	return request.get(`blog-comments/report?answerId=${id}`)
}


// 根据帖子id查找帖子评论
export const getComments = (data) => {
	return request.get(`blog-comments/getAllComments/${data}`, {}, {
		noAuth: true
	})
}

// 点赞评论
export const likeComment = (data) => {
	return request.get(`blog-comments/like/${data}`, {}, {
		noAuth: true
	})
}

// 增加评论
export const addComment = (data) => {
	return request.post('blog-comments', data, {
		noAuth: true
	})
}

// 查询自己的帖子

export const getMyComment = (data) => {
	return request.get('blog/getBlogByUserId', {
		pageNum: 1,
		pageSize: 5,
		...data
	}, {
		noAuth: true
	})
}


// 查询用户点赞了的帖子

export const getGoodBlog = (data) => {
	return request.get('blog/getUserLikedBlogList', {
		pageNum: 1,
		pageSize: 5,
		...data
	}, {
		noAuth: true
	})
}

// 滚动查询关注帖子

export const getBlogFollow = (lastId, offset) => {
	return request.get('blog/of/follow', {
		lastId: lastId || new Date().getTime(),
		offset: offset || 0,
	})
}

// 新增帖子

export const addCard = (data) => {
	return request.post('blog', data, {
		noAuth: true
	})
}

// 获取所有的活动

export const getActivity = (data) => {
	return request.get('activity/queryActivityList', {
		pageNum: 1,
		pageSize: 5,
		...data
	}, {
		noAuth: true
	})
}
// 根据id查询帖子
export const getActivityById = (id) => {
	return request.get(`activity/${id}`, {}, {
		noAuth: true
	})
}

// 活动报名

export const joinActivity = (id) => {
	return request.put(`activity/join/${id}`, {}, {
		noAuth: true
	})
}

// 关注/取关用户
export const follow = (id, flag) => {
	return request.put(`follow/${id}/${flag}`, {}, {
		noAuth: true
	})
}

// 浏览帖子记录
export const getforward = (data) => {
	return request.get('blog/readBlogList', {
		pageNum: 1,
		pageSize: 5,
		...data
	}, {
		noAuth: true
	})
}